package com.dotflat.satistics.repository.crm.impl;

import com.dotflat.satistics.repository.crm.ProductRepository;
import com.matt.domain.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/8/28
 * *******************************
 */
@Repository
public class ProductRepositoryImpl implements ProductRepository {

    @Autowired
    private JdbcTemplate crmJdbcTemplate;

    @Override
    public List<Product> findAllActiveProduct(String areaId) {
        String sql ="select id, name from product WHERE isVisible =? and areaId =?";
        List<Product> staffAreaList = crmJdbcTemplate.query(sql, new Object[]{1, areaId}, new BeanPropertyRowMapper(Product.class));
        return staffAreaList;
    }

}
